﻿/// <reference path="TurboBase.js" />
/// <reference path="../General/General.js" />
/// <reference path="../General/Json.js" />
/// <reference path="../Enums/DataDirection.js" />
/// <reference path="../Enums/DataType.js" />



var $FieldBinding = TA.Turbo.Common.FieldBinding = function FieldBinding()
{
}
$FieldBinding.Inherit(BaseJsonSerializable);
$FieldBinding.Inherit(BaseJsonDeserializable);

$FieldBinding.prototype.Field = "";
$FieldBinding.prototype.Format = "";
$FieldBinding.prototype.Direction = DataDirection.Both;
$FieldBinding.prototype.StoringType = DataType.String;
$FieldBinding.prototype.BindingType = DataType.String;

$FieldBinding.prototype.get_IsDirty = function get_IsDirty()
{
	return !String.IsNullOrEmpty(this.Field)
		|| !String.IsNullOrEmpty(this.Format)
		|| this.Direction != DataDirection.Both
		|| this.StoringType != DataType.String
		|| this.BindingType != DataType.String;
}
$FieldBinding.prototype.SerializeContents = function SerializeContents(jw)
{
	var _____a;
	if (_____a) jw = new JsonWriter();

	if (!String.IsNullOrEmpty(this.Field))
	{
		jw.PropertyName("F");
		jw.Value(this.Field);
	}

	if (!String.IsNullOrEmpty(this.Format))
	{
		jw.PropertyName("O");
		jw.Value(this.Format);
	}

	if (this.Direction != DataDirection.Both)
	{
		jw.PropertyName("D");
		jw.Value(this.Direction);
	}

	if (this.StoringType != DataType.String)
	{
		jw.PropertyName("S");
		jw.Value(this.StoringType);
	}

	if (this.BindingType != DataType.String)
	{
		jw.PropertyName("B");
		jw.Value(this.StoringType);
	}
}
$FieldBinding.prototype.DeserializeContent = function DeserializeContent(prShortName, value)
{
	switch (prShortName)
	{
		case "F": this.Field = value; break;
		case "O": this.Format = value; break;
		case "D": this.Direction = value; break;
		case "S": this.StoringType = value; break;
		case "B": this.BindingType = value; break;
	}
}
